(function() {
  var __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  this.EditProfileView = (function(_super) {

    __extends(EditProfileView, _super);

    function EditProfileView() {
      return EditProfileView.__super__.constructor.apply(this, arguments);
    }

    EditProfileView.prototype.initialize = function() {
      EditProfileView.__super__.initialize.apply(this, arguments);
      this.setElement("#main");
      this.model.bind("change", this.render);
      return this.model.fetch();
    };

    EditProfileView.prototype.render = function() {
      var _this = this;
      return this.GetTemplate(SiteMap.Account.EditTemplate, function(compiledTemplate) {
        $(_this.el).html(compiledTemplate(_this.model.toJSON()));
        return $("#Avatar").ImageUpload();
      });
    };

    EditProfileView.prototype.events = {
      "click button.Edit": "Save"
    };

    EditProfileView.prototype.Save = function() {
      var data,
        _this = this;
      Loading.Start();
      Messages.WriteMessage('Saving user.');
      data = $(this.el).find("form.general").serialize();
      return $.ajax({
        type: "POST",
        url: SiteMap.Account.Save,
        data: data,
        success: function(response) {
          if ((response.SuccessMessage != null) && response.SuccessMessage.length) {
            Messages.WriteSuccessMessage(response.SuccessMessage);
            Backbone.history.navigate('', {
              trigger: true
            });
            return Loading.Stop();
          } else {
            Messages.WriteErrors(response.Errors);
            return Loading.Stop();
          }
        }
      });
    };

    return EditProfileView;

  })(CustomView);

}).call(this);
